class UserSessionsController < ApplicationController
  before_filter :not_user_required, :only=>[:new]
  #before_filter :require_admin, :only =>[:index,:show,:new,:edit,:create,:update,:destroy]
  def index
    redirect_to :action => "new"
  end

  def new
    @user_session = UserSession.new
  end
  
  def create
    @user_session = UserSession.new(params[:user_session])
    if @user_session.save
      flash[:notice] = "inicio de sesión concedido"
      redirect_to :controller=>'projects'
    else
      flash[:notice] = "Error al iniciar la sesión"
      render :action => :new
    end
  end
  
  def destroy
    current_user_session.destroy
    flash[:notice] = "Cierre de sesión exitoso!"
      redirect_to ''
  end
end
